import React, { useState, useEffect } from 'react';
import { Row, Col } from 'antd';
import { Input } from 'antd';
import { DatePicker, Space, Modal } from 'antd';
import { Select } from 'antd';
import { Button, Menu, Dropdown, Form, Radio } from 'antd';
const { RangePicker } = DatePicker;
import { Table } from 'antd';
const { Option } = Select;
import { history } from 'umi';
import { DownOutlined, UpOutlined } from '@ant-design/icons';

import { FormInstance } from 'antd/lib/form';
import { Transfer } from 'antd';
import request from '../../../http';

//教师信息维护
const xinzheng = () => {
  //公共接口
  const [College, setCollege] = useState([{}]);
  const [Major, setMajor] = useState([{}]);
  const [Grade, setGrade] = useState([{}]);
  const [Class, setClass] = useState([{}]);
  const [HeadMaster, setHeadMaster] = useState([{}]);
  const [IsGraduation, setIsGraduation] = useState([{}]);

  //获取输入的值
  const [gCollege, setgCollege] = useState(0);
  const [gMajor, setgMajor] = useState(0);
  const [gGrade, setgGrade] = useState(0);
  const [gClass1, setgClass1] = useState(0);
  const [gHeadMaster, setgHeadMaster] = useState(0);
  const [gIsGraduation, setgIsGraduation] = useState(0);

  const [count, setcount] = useState(0);

  //提交表单
  const onSubmit = (value: any) => {
    setcount(count + 1);
    console.log(count);
  };

  useEffect(() => {
    //院系请求
    request.post('/common/a_t_s/queryAllGrades').then((res) => {
      // console.log("院系请求成功了",res.data)
      setCollege(res.data);
    });

    //专业请求
    request.post('/common/a_t_s/queryAllMajor').then((res) => {
      // console.log("院系请求成功了",res.data)
      setMajor(res.data);
    });

    //年级请求
    request.post('/common/a_t_s/enumGrade').then((res) => {
      // console.log("年级请求成功了",res.data)
      setGrade(res.data);
    });

    //班级请求
    request.post('/common/a_t/enumClass').then((res) => {
      // console.log("班级请求成功了",res.data)
      setClass(res.data);
    });

    //实训老师请求
    request.post('/common/admin/queryTeacherNames').then((res) => {
      // console.log("实训老师请求成功了",res.data)
      setHeadMaster(res.data);
    });

    //是否已结业请求
    request.get('/studentManage/admin/AdminGetAllGraduated').then((res) => {
      // console.log('是否已结业请求成功了', res.data);
      setIsGraduation(res.data);
    });
  }, []);

  const formItemLayout = {
    labelCol: {
      // xs: { span: 24 },
      // sm: { span: 8 },
    },
    wrapperCol: {
      xs: { span: 24 },
      sm: { span: 16 },
    },
  };

  const [form] = Form.useForm();
  const onGenderChange = (value: string) => {
    switch (value) {
      case 'male':
        form.setFieldsValue({ note: 'Hi, man!' });
        return;
      case 'female':
        form.setFieldsValue({ note: 'Hi, lady!' });
        return;
      case 'other':
        form.setFieldsValue({ note: 'Hi there!' });
    }
  };

  return (
    <div>
      <Form onValuesChange={onSubmit} {...formItemLayout}>
        <div>
          <div style={{ marginLeft: '0px', float: 'left', width: '300px' }}>
            <Form.Item label="院系：">
              <Select
                placeholder="请选择"
                onChange={(e, index) => {
                  setgCollege(parseInt(index.key));
                }}
                allowClear
              >
                {College.map((cNameObj: any) => {
                  return (
                    <Option key={cNameObj.id} value={cNameObj.format}>
                      {cNameObj.format}
                    </Option>
                  );
                })}
              </Select>
            </Form.Item>
          </div>

          <div style={{ marginLeft: '0px', float: 'left', width: '300px' }}>
            <Form.Item label="专业：">
              <Select
                placeholder="请选择"
                onChange={(e, index) => {
                  setgMajor(parseInt(index.key));
                }}
                allowClear
              >
                {Major.map((cNameObj: any) => {
                  return (
                    <Option key={cNameObj.id} value={cNameObj.format}>
                      {cNameObj.format}
                    </Option>
                  );
                })}
              </Select>
            </Form.Item>
          </div>

          <div style={{ marginLeft: '0px', float: 'left', width: '300px' }}>
            <Form.Item label="年级：">
              <Select
                placeholder="请选择"
                onChange={(e, index) => {
                  setgGrade(parseInt(index.key));
                }}
                allowClear
              >
                {Grade.map((cNameObj: any) => {
                  return (
                    <Option key={cNameObj.id} value={cNameObj.format}>
                      {cNameObj.format}
                    </Option>
                  );
                })}
              </Select>
            </Form.Item>
          </div>

          <div style={{ marginLeft: '0px', float: 'left', width: '300px' }}>
            <Form.Item label="班级：">
              <Select
                placeholder="请选择"
                onChange={(e, index) => {
                  setgClass1(parseInt(index.key));
                }}
                allowClear
              >
                {Class.map((cNameObj: any) => {
                  return (
                    <Option key={cNameObj.id} value={cNameObj.format}>
                      {cNameObj.format}
                    </Option>
                  );
                })}
              </Select>
            </Form.Item>
          </div>

          <div style={{ marginLeft: '0px', float: 'left', width: '300px' }}>
            <Form.Item label="班主任：">
              <Select
                placeholder="请选择"
                onChange={(e, index) => {
                  setgHeadMaster(parseInt(index.key));
                }}
                allowClear
              >
                {HeadMaster.map((cNameObj: any) => {
                  return (
                    <Option key={cNameObj.id} value={cNameObj.format}>
                      {cNameObj.format}
                    </Option>
                  );
                })}
              </Select>
            </Form.Item>
          </div>

          <div style={{ marginLeft: '0px', float: 'left', width: '300px' }}>
            <Form.Item label="是否已结业：">
              <Select
                placeholder="请选择"
                onChange={(e, index) => {
                  setgIsGraduation(parseInt(index.key));
                }}
                allowClear
              >
                {IsGraduation.map((cNameObj: any) => {
                  return (
                    <Option key={cNameObj.id} value={cNameObj.id}>
                      {cNameObj.graduatedName}
                    </Option>
                  );
                })}
              </Select>
            </Form.Item>
          </div>

          <div style={{ clear: 'left', width: '1000px' }}></div>
        </div>
      </Form>
    </div>
  );
};

export default xinzheng;
